#include "common.hpp"

int main()
{
    umask(0);
    int infd = open(FifoName, O_RDONLY);
    if (infd < 0)
        ERR_EXIT("open");
    else
        std::cout << "open fifo success" << std::endl;
    
    int outfd = open("test.txt", O_CREAT | O_WRONLY | O_TRUNC,0666);
    if (outfd < 0)
        ERR_EXIT("open");
    else
        std::cout << "open fifo success" << std::endl;
    char buffer[1024];    
    while(int n = read(infd, buffer, sizeof(buffer) - 1))
    {
        write(outfd, buffer, n);
    }
    return 0;
}